<div class="container reg-page">
    <div class="col-md-12">
        <div class="tab">
            <div class="tab-pane" data-click="false">
            	<a href="javascript:void(0);" style="color:#ff5991;">
                	<i class="border-top"></i>
					买家注册
				</a>
            </div>
             <div class="tab-pane gray">
             	<a href="javascript:void(0);" style="color:#c7c7c7;">
                	<i class="border-top gray"></i>
				 	商家注册
				 </a>
            </div>
        </div>
        <div class="tab-content">
            <div class="pull-left reg-box">
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'reg-form',
                ));
                ?>
                 <?php echo $form->errorSummary($model); ?>
                <table>
                    <tr>
                        <td class="title">邮箱:</td>
                        <td>
                            <?php echo $form->textField($model, 'email', array('placeholder' => "请输入您的邮箱",'class'=>'input')); ?>
                        </td>
                    </tr>
                    <!--
                    <tr>
                        <td class="title">类型:</td>
                        <td class="radios">
                            <?php echo $form->radioButtonList($model, 'kind',array('1'=>'买家类型','0'=>'商家类型'),array('class'=>'radio'));?>
                          
                        </td>
                    </tr>
                    -->
                    <?php if(!empty(Yii::app()->session['invite'])){  ?>
                        <tr>
                            <td class="title">手机号码:</td>
                            <td>
                                <input name="MembersModel[phone]"   placeholder="请输入您的手机" id="snscode_phone" type="text" value="" class="input">
                            </td>
                        </tr>
                        <tr>
                            <td class="title">验证码:</td>
                            <td>
                                 <input name="snscode" style=" width:50px;" id="phone" type="text" value="" class="input">
                                 <input type="button" id="snscode" value="免费获取验证码" style="width:120px;height: 35px;" />
                            </td>
                        </tr>
                    <?php } ?>

                    <tr>
                        <td class="title">密码:</td>
                        <td><?php echo $form->passwordField($model, 'password', array('placeholder' => "请输入密码",'class'=>'input'));?></td>
                    </tr>
                    <tr>
                        <td class="title">确认密码:</td>
                        <td><?php echo $form->passwordField($model, 'repassword', array('placeholder' => "请重复密码",'class'=>'input'));?></td>
                    </tr>
                    <tr>
                        <td class="title">验证码:</td>
                        <td>
                             <?php echo $form->textField($model,'verifyCode', array('placeholder' => "验证码",'class'=>'input2')); ?>  
                            <?php $this->widget('CCaptcha',array('showRefreshButton'=>true,'clickableImage'=>true,'buttonLabel'=>'看不清')); ?> 
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><?php echo $form->checkBox($model, 'agreement', array('class'=>'checkbox'));?>我已经认真阅读并同意1折网的《用户注册协议》 </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" class="btn reg-spt " value=""></td>
                    </tr>
                </table>
                <?php $this->endWidget(); ?>
            </div>
            <div class="pull-left login-box">
                <p>已有1折网账号</p>
                <p><a href="<?php echo $this->createUrl('/user/login/login'); ?>">直接登录</a></p>
            </div>
            <div class="clearfix"></div>
        </div>
        
    </div>
</div>

<?php include $this->getViewFile('//user/lib/choise'); ?>

<script type="text/javascript">

$('.tab-pane:not([data-click="false"])').click(function(){
	window.location.href = "<?php echo $this->createUrl('/user/user/regmobile', array('choise'=>'1')); ?>";
});


<?php if(!empty(Yii::app()->session['invite'])){  ?>

var wait = 60;  //60秒才能发送一次
if (getCookie("time") == null || getCookie("time") < 0){
    setCookie("time",wait,wait);
}else if(getCookie("time") != wait)
{
    timeRef();
}

//计时器
function time(o) {
    
        if(!o)
            var o = document.getElementById("snscode");
        
        if(getCookie("time") == wait){
            var moblie = $('#snscode_phone').val();
            $.getJSON('<?php echo YzwController::U('Public/snscode') ?>',{moblie:moblie},function(data){
                if(data.status){
                    
                }else{
                    alert(data.info);
                }
            });
        }
    
        if (getCookie("time") == null || getCookie("time") <= 0) {
            o.removeAttribute("disabled");
            o.value="免费获取验证码";

        } else {

            timeRef();
            
        }
}
//刷新按钮
function timeRef(){
    if(!o)
        var o = document.getElementById("snscode");
    waittime = getCookie("time");
    o.setAttribute("disabled", true);
    o.value="重新发送(" + waittime + ")";
    waittime--;
    setCookie("time",waittime);
    setTimeout(function() {
        time(o)
    },
    1000)
}
//点击获取验证码
document.getElementById("snscode").onclick=function(){
    var moblie = $('#snscode_phone').val();
    if(moblie == ''){
        alert('手机号不能为空！');
        return false;
    }
    if(!(/^1[3|4|5|8][0-9]\d{8}$/.test(moblie))){ 
        alert("手机号码格式不正确");  
        return false; 
    }
    setCookie("time",wait,wait);
    time(this);
}

//js设置Cookie
function setCookie(name,value,time)
{
    var exp = new Date();
    exp.setTime(exp.getTime() + time * 1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//js获取Cookie
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
        return (arr[2]);
    else
        return null;
}



<?php } ?>

</script>



